<template>
  <div class="carousel">
    <el-carousel :interval="4000" type="card" class="carousel_content">
      <el-carousel-item v-for="item in items" :key="item">
        <img :src="item.imgUrl" alt="" class="item_img">
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { listBanner } from '@/apis/banner.js'

const getData = async () => {
  let query = {pageNum: 1, pageSize: 4}
  const res = await listBanner(query);
  items.value = res.rows;
}

getData()

const items = ref([])

</script>

<style scoped>
.carousel {
  width: 100%;
  height: 55vh;
  background-color: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-top: 2%;
}

.carousel_content{
  width: 80%;
  height: 90%;
}

.item_img{
  height: 60vh;
  width: 80vh;
  object-fit: cover;
}
</style>
